import request from '@/utils/request'

enum API {
    SPULIST = '/admin/product/',
    TMALL = '/admin/product/baseTrademark/getTrademarkList',
    ALLATTR = '/admin/product/baseSaleAttrList',
    IMGLIST = '/admin/product/spuImageList/',
    SALEATTR = '/admin/product/spuSaleAttrList/',
    ADDSPU = '/admin/product/saveSpuInfo',
    UPDATESPU = '/admin/product/updateSpuInfo',
    DELETESPU = '/admin/product/deleteSpu/',
    ATTRARR = '/admin/product/attrInfoList/',
    // 添加sku
    ADDSKU = '/admin/product/saveSkuInfo',
    // 查看sku列表
    SKULIST = '/admin/product/findBySpuId/'

}


// 获取spu数据的接口
export const reqSpuList = (page: number, limit: number, category3Id: number | string) => request.get(API.SPULIST + `${page}/${limit}/?category3Id=${category3Id}`)

// 获取全部品牌数据的接口
export const reqAllTrademark = () => request.get(API.TMALL)

// 获取全部销售属性的接口
export const reqAllAttr = () => request.get(API.ALLATTR)

// 获取照片墙列表的接口
export const reqImgList = (spuId: number | string) => request.get(API.IMGLIST + spuId)

// 获取已有的销售属性的接口
export const reqSaleAttrList = (spuId: number | string) => request.get(API.SALEATTR + spuId)

// 添加或修改SPU
export const reqAddOrUpdateSpu = (data)=>{
    // 有id修改，无添加
    if(data.id){
        return request.post(API.UPDATESPU,data)
    }else{
        return request.post(API.ADDSPU,data)
    }
}
// 删除SPU
export const reqDeleteSpu = (spuId:number)=>request.delete(API.DELETESPU+spuId)

// 获取平台属性的接口
export const reqAttrArr = (category1Id:number|string,category2Id:number|string,category3Id:number|string)=>request.get(API.ATTRARR+`${category1Id}/${category2Id}/${category3Id}`)

// 添加SKU
export const reqAddSku = (data:any) =>request.post(API.ADDSKU,data)

// 查看SKU列表
export const reqSkuList = (spuId:number|string)=>request.get(API.SKULIST+spuId)